<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="Model.*"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>

<script type="text/javascript">
function sbmit1(){	
    
		var Name = document.getElementById("TeacherName").value;
	    var ID = document.getElementById("TeacherID").value;	    
	    
	    
	    var url = "../teacherservlet";
	    var postParam = "TeacherID=" + ID + "&TeacherName=" + Name + "&opType=addTeacher";
	    var ajax = false;
// 	     alert(postParam);
	    if (window.XMLHttpRequest){
	        ajax = new XMLHttpRequest();
	        if (ajax.overrideMimeType) {
	            ajax.overrideMimeType("text/xml");
	        }
	    }else if (window.ActiveXObject){
	        try{
	            ajax = new ActiveXObject("Msxml2.XMLHTTP");
	        }catch(e){
	            try{
	                ajax = new ActiveXObject("Microsoft.XMLHTTP");
	            }catch (e){;}
	        }
	    }
	    if (!ajax) {
	        window.alert("不能创建XMLHttpRequest对象实例.");            
	        return false;
	    }
	    ajax.open("POST", url, true);
	    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    ajax.send(postParam);    
	   	
	    ajax.onreadystatechange = function() {        	      
	    	if(ajax.readyState==4){
	    		if(ajax.responseText==1){
	    			alert("添加成功！");    			
	    		}
	    		else{
	    			alert("添加失败！");
	    		}
	    		        		
	    	}
			
	    }
	
}
function sbmit2(){	
	var CurriculumID = document.getElementById("CurriculumID").value;
    var CurriculumName = document.getElementById("CurriculumName").value;
    var CurriculumTeacherID = document.getElementById("CurriculumTeacherID").value;
    var CurriculumTime = document.getElementById("CurriculumTime").value;    
    var CurriculumMaxnum = document.getElementById("CurriculumMaxnum").value;
    var CurriculumNownum = 0;
    
    var url = "../curriculumservlet";
    var postParam = "CurriculumID=" + CurriculumID +"&CurriculumName=" + CurriculumName 
    + "&CurriculumTeacherID=" + CurriculumTeacherID + "&CurriculumTime=" 
    + CurriculumTime + "&CurriculumMaxnum=" + CurriculumMaxnum 
    + "&CurriculumNownum=" + CurriculumNownum + "&opType=addCurriculum";
    
    var ajax = false;
//    alert(postParam);
   
   if (window.XMLHttpRequest){
       ajax = new XMLHttpRequest();
       if (ajax.overrideMimeType) {
           ajax.overrideMimeType("text/xml");
       }
   }else if (window.ActiveXObject){
       try{
           ajax = new ActiveXObject("Msxml2.XMLHTTP");
       }catch(e){
           try{
               ajax = new ActiveXObject("Microsoft.XMLHTTP");
           }catch (e){;}
       }
   }
   if (!ajax) {
       window.alert("不能创建XMLHttpRequest对象实例.");            
       return false;
   }
   ajax.open("POST", url, true);
   ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   ajax.send(postParam);  
   ajax.onreadystatechange = function() {        	      
   	if(ajax.readyState==4){
   		if(ajax.responseText==1){
   			alert("添加成功！");    			
   		}
   		else{
   			alert("添加失败！");
   		}   		        	
   	}		
   }
   
}
</script>
</head>
<body>
<div align="center">
<!-- 代码仅作测试后台功能用，具体业务实现当根据需求详改。 -->
		<form method="get" name="regform" action=".">
				<tr>					
					<td align="right" height="60"><p>教练姓名</p></td>
					<td align="left"><input id="TeacherName"
						name="TeacherName" type="text" value=""></td>
						
					<td align="right" height="60"><p>教练ID</p></td>
					<td align="left"><input id="TeacherID"
						name="TeacherID" type="text" value=""></td>
						
					<td align="center" height="60">&nbsp;</td>
					<td align="left" height="60">
					<input id="register" name="register" type="button" value="添加教练" onclick="sbmit1()"></td>

					<td align="right" height="60"><p>课程ID</p></td>
					<td align="left"><input id="CurriculumID"
						name="CurriculumID" type="text" value=""></td>
						
					<td align="right" height="60"><p>课程名</p></td>
					<td align="left"><input id="CurriculumName"
						name="CurriculumName" type="text" value=""></td>

					<td align="right" height="60"><p>课程教练ID</p></td>
					<td align="left"><input id="CurriculumTeacherID"
						name="CurriculumTeacherID" type="text" value=""></td>
						
					<td align="right" height="60"><p>上课时间</p></td>
					<td align="left"><input id="CurriculumTime"
						name="CurriculumTime" type="text" value=""></td>
					
					<td align="right" height="60"><p>最大上课人数</p></td>
					<td align="left"><input id="CurriculumMaxnum"
						name="CurriculumMaxnum" type="text" value=""></td>
					
					<td align="center" height="60">&nbsp;</td>
					<td align="left" height="60">
					<input id="operate" name="operate" type="button" value="增加课程安排" onclick="sbmit2()"></td>
				</tr>
			</form>
			</div>
</body>
</html>

